<template>
	<view class="gameitem">
		<view class="piclog" v-if="!obj.op"></view>
		<image :src="obj.gameImage" class="picitem" v-if="obj.op" @click="togame" lazy-load></image>
		<view class="scbox bj_center">
			<image :src="'/static/game/c'+obj.fav+'.png'" mode="widthFix"></image>
		</view>
	</view>
</template>

<script setup>
	import {
		onLoad
	} from "@dcloudio/uni-app"
	import {
		ref,
		watch,
		inject
	} from "vue";
	import common from "../../js/common";
	const opgc = inject("opgc");
	const props = defineProps({
		obj: {
			type: Object,
			default: {}
		}
	});

	watch(() => props.obj.op, (val) => {

	})

	function togame() {

		if (!getApp().globalData.userInfo) {
			opgc(1, 2)
			return
		}

		common.gameUrl({
			gameId: props.obj.gameId,
			id: props.obj.gameId
		}, {
			"token": getApp().globalData.userInfo.token
		}).then(res => {
			if (res.statusCode == 200 && res.data.success) {
				gu = res.data.data.game_url
				uni.navigateTo({
					url: "/pages/index/gb/gb"
				})
			}
		})
	}
</script>

<style scoped lang="scss">
	.gameitem {
		float: left;
		width: 25%;
		padding: 0 3rpx;
		position: relative;
		margin-bottom: 6rpx;

		.picitem {
			width: 100%;
			height: 224rpx;
		}

		.piclog {
			width: 100%;
			height: 224rpx;
			border-radius: 12rpx;
			background: #003311;
		}

		.scbox {
			width: 44rpx;
			height: 48rpx;
			position: absolute;
			top: 0;
			right: 10rpx;
			background: url("/static/game/scb.png") no-repeat center center;
			background-size: 100% 100%;

			image {
				width: 28rpx;
			}
		}
	}

	.gameitem:nth-child(4n+1) {
		padding: 0 6rpx 0 0;
	}

	.gameitem:nth-child(4n+4) {
		padding: 0 0 0 6rpx;
	}
</style>